<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
	<link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
	<script type="text/javascript" th:src="@{/static/jquery-2.1.4.js}"></script>
	<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
	<script type="text/javascript" th:src="@{/static/mylayer.js}"></script>
</head>
<body>
    <form id="formId" class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">博客分类名</label>
            <div class="layui-input-block">
                <input type="text" name="name" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn" onclick="submitForm()" lay-submit="" lay-filter="submitForm">添加</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
        </div>
    </form>

    <script>
        function submitForm() {
            $.post(
                '/blogType/add',
                $('#formId').serialize(),  // {'name':'zhansgan','password':'123'}
                function(result) {
                    if (result.code == 0) {
                        mylayer.okMsg(result.msg);
                        setInterval(function() {
                            //关闭弹出框
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            //刷新父页面
                            window.parent.location.reload();
                        }, 2000)
                    }
                },
                'json'
            );
        }
    </script>
</body>
</html>